package com.ruoyi.web.controller.gameType;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.GameType;
import com.ruoyi.system.service.GameTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 娱乐类型管理Controller
 * 
 * @author ruoyi
 * @date 2025-05-25
 */
@RestController
@RequestMapping("/gameType/gameType")
public class GameTypeController extends BaseController
{
    @Autowired
    private GameTypeService gameTypeService;

    /**
     * 查询娱乐类型管理列表
     */
    @PreAuthorize("@ss.hasPermi('gameType:gameType:list')")
    @GetMapping("/list")
    public TableDataInfo list(GameType gameType)
    {
        startPage();
        List<GameType> list = gameTypeService.selectGameTypeList(gameType);
        return getDataTable(list);
    }

    /**
     * 导出娱乐类型管理列表
     */
    @PreAuthorize("@ss.hasPermi('gameType:gameType:export')")
    @Log(title = "娱乐类型管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GameType gameType)
    {
        List<GameType> list = gameTypeService.selectGameTypeList(gameType);
        ExcelUtil<GameType> util = new ExcelUtil<GameType>(GameType.class);
        util.exportExcel(response, list, "娱乐类型管理数据");
    }

    /**
     * 获取娱乐类型管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('gameType:gameType:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(gameTypeService.selectGameTypeById(id));
    }

    /**
     * 新增娱乐类型管理
     */
    @PreAuthorize("@ss.hasPermi('gameType:gameType:add')")
    @Log(title = "娱乐类型管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GameType gameType)
    {
        return toAjax(gameTypeService.insertGameType(gameType));
    }

    /**
     * 修改娱乐类型管理
     */
    @PreAuthorize("@ss.hasPermi('gameType:gameType:edit')")
    @Log(title = "娱乐类型管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GameType gameType)
    {
        return toAjax(gameTypeService.updateGameType(gameType));
    }

    /**
     * 删除娱乐类型管理
     */
    @PreAuthorize("@ss.hasPermi('gameType:gameType:remove')")
    @Log(title = "娱乐类型管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gameTypeService.deleteGameTypeByIds(ids));
    }

}
